#ifndef CONNECTION_H
#define CONNECTION_H

#include <QtNetwork>
#include <QObject>
#include <QTcpSocket>
#include "connection.h"

class Connection: public QTcpSocket
{

public:
    Connection (QObject* parent = 0);
    bool hasConnection ();

signals:
    void connectionEstablished ();
    void connectionLost ();
    void connectionError (QAbstractSocket::SocketError error, const QString errorString);
    void newMessage ();

public slots:
    void openConnection (const QString &serverAddress);
    void closeConnection (const QString &serverAddress);
    bool sendMessage ();

private slots:
    void socketConnected ();
    void processReadyRead ();
    void socketError (QAbstractSocket::SocketError error);

private:
    struct Message {
        QBitArray TYPE;
        int GAME_ID;
        QString NAME;
        QVector <QString> PEERS_LIST;
        QVector <QString> POSITION;
    };

    quint16 sport = 5560;
    Message *msg;

};

#endif // CONNECTION_H
